import { Period } from "@/types/config"
import { IncomeItemForInteraction, SiftedIncome } from "@/types/income"
import request from "@/utils/request"

export function deleteIncome(id: number) {
    return request({
        method: 'delete',
        url: '/income/delete',
        params: { id }
    })
}

export function getOnePageIncome(siftIncome: SiftedIncome) {
    return request({
        method: 'get',
        url: '/income/page',
        params: siftIncome
    })
}

export function modifyIncome(income: IncomeItemForInteraction) {
    return request({
        method: 'put',
        url: '/income',
        data: income
    })
}

export function addIncome(income: IncomeItemForInteraction) {
    return request({
        method: 'post',
        url: '/income/save',
        data: income
    })
}

export function getDetailedIncome(period: Period) {
    return request({
        method: 'get',
        url: '/income/detailedIncome',
        params: period
    })
}

export function getClassifiedIncome(period: Period) {
    return request({
        method: 'get',
        url: '/income/classifiedIncome',
        params: period
    })
}

export function addIncomeType(typeName: String) {
    return request({
        method: 'post',
        url: '/first/save',
        data: { typeName }
    })
}

export function deleteIncomeTypes(ids: Number[]) {
    return request({
        method: 'delete',
        url: '/first/delete',
        params: { ids: ids.toString() }
    })
}

export function getIncomeTypeList() {
    return request({
        method: 'get',
        url: '/first/select'
    })
}